import java.util.*;

public class Example1 {

   public static void main( String args[] ) {
	for ( int i = 0; i < 10; i ++ )
		( new Thread ( new XYZ( i )) ).start();
   }
}

class XYZ implements Runnable {
   static   Random rdm = new Random( ) ;
   int myID;
   public XYZ( int id ) { myID = id ; }

   public void run() {

	while ( true ) {
	    for ( int i = 0 ; i < myID; i ++ ) System.out.printf("     " );
	    System.out.printf(" I am thread %d\n", myID);
	    try { Thread.sleep( rdm.nextInt(4000-1000 + 1) + 1000 ) ; } catch (InterruptedException e) { } 
	}
   }
}
